package com.haoshui.handler.exception;


import com.haoshui.domain.ResponseResult;
import com.haoshui.exception.SystemException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobaExceptionHandler {

    @ExceptionHandler(SystemException.class)
    public ResponseResult systemException(SystemException e){
        ResponseResult responseResult = ResponseResult.errorResult(e.getCode(), e.getMsg());

        //打印异常信息
        log.error("出现异常 {}" ,e);

        //返回
        return responseResult;
    }
}
